package com.vegetable.modules.entity.outbound.vo;

import cn.hutool.core.util.NumberUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.vegetable.common.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 销售出库单
 * </p>
 *
 * @author wangruijie
 * @since 2024-04-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="销售额统计对象", description="销售额统计对象")
public class SalesOutGeneralVO extends BaseEntity {
    @ApiModelProperty(value = "客户id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long customerId;
    @ApiModelProperty(value = "客户名称")
    private String customerName;
    @ApiModelProperty(value = "订单编号")
    private String docNo;
    @ApiModelProperty(value = "订单id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long salesId;
    @ApiModelProperty(value = "订单时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date orderTime;
    @ApiModelProperty(value = "业务员名称")
    private String salesmanName;
    @ApiModelProperty(value = "销售额")
    private BigDecimal salesVolume;
    @ApiModelProperty(value = "销售重量")
    private BigDecimal totalWeight;
    @ApiModelProperty(value = "发车次数")
    private Integer trainTimes;
    @ApiModelProperty(value = "利润总和")
    private BigDecimal totalProfit;
    @ApiModelProperty(value = "扣款总和")
    private BigDecimal deductionMoney;
    @ApiModelProperty(value = "回款总和")
    private BigDecimal receivedMoney;
    @ApiModelProperty(value = "欠款总和")
    private BigDecimal notReceivedMoney;

    public BigDecimal getNotReceivedMoney() {
        return NumberUtil.sub(salesVolume, receivedMoney, deductionMoney);
    }
}
